﻿#region License
/*Copyright (c) 2010 Andrew Collard (andrewcollard@hotmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.*/
#endregion

using System.IO;

namespace TorchView.Game
{
  /// <summary>
  /// Block of all the places a character has been.
  /// Town is the first entry.
  /// Main contains the entire main storyline. basically tracks how far down you have gone in the main story, and the portals activated.
  /// Hatch maps are the guy who has a book and wand that asks you to retrieve an item.
  /// Treasure maps are the ones the ember collector rewarded.
  /// Puzzle maps occur when you get a short extra map as part of a Hatch or Treasure map.
  /// Random maps are maps bought from the store.
  /// Random Dungeons are the ones entered in the Southeast corner of town.
  /// </summary>

  public sealed class PastDungeon
  {
    public string Name { get; set; }
    public int PlayerEntryLevel { get; set; }  //?
    public uint DeepestFloor { get; set; } //?
    public uint MapSeed { get; set; }
    public uint[] Portals { get; set; }

    public static PastDungeon Read(BinaryReader reader)
    {
      PastDungeon pastdungeon = new PastDungeon();
      pastdungeon.Name = SVTHelper.ReadString(reader);
      pastdungeon.PlayerEntryLevel = reader.ReadInt32();
      pastdungeon.DeepestFloor = reader.ReadUInt32();
      pastdungeon.MapSeed = reader.ReadUInt32();
      var count = reader.ReadUInt32();
      uint[] unknown3 = new uint[count];
      for (int i = 0; i < count; i++)
        unknown3[i] = reader.ReadUInt32();
      pastdungeon.Portals = unknown3;
      return pastdungeon;
    }

    public override string ToString()
    {
      return "Dungeon: " + Name;
    }
  }
}
